﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Directory.Web
{
	public partial class Controls_CategoryNavigator : System.Web.UI.UserControl
	{
		protected void Page_Load(object sender, EventArgs e)
		{
			if (!IsPostBack)
			{
				IList<Directory.Model.CategoryInfo> childsList = CategoryDataProxy.GetChildsOfCategory(CategoryId);
				if (childsList.Count <= 4)
				{
					rptChilds.DataSource = childsList;
				}
				else
				{
					IList<Directory.Model.CategoryInfo> childs_tmp = new List<Directory.Model.CategoryInfo>();
					for (int i = 0; i < 5; i++)
					{
						childs_tmp.Insert(i, childsList[i]);
					}
					rptChilds.DataSource = childs_tmp;
				}
				rptChilds.DataBind();
			}
		}

		private int _categoryId = -999;
		public int CategoryId
		{
			get { return _categoryId; }
			set { _categoryId = value; }
		}

		private string _title = string.Empty;
		public string Title
		{
			get { return _title; }
			set { _title = value; }
		}
	}
}
